package app.error;

import lombok.Getter;

@Getter
public class GatewayError {

    /**
     * 错误类型码
     */
    private int code;
    /**
     * 错误类型描述信息
     */
    private String msg;

    /**
     * HTTP状态码
     */
    private int status;

    GatewayError(int status, int code, String msg) {
        this.status = status;
        this.code = code;
        this.msg = msg;
    }

    public static GatewayError fail(int code, String msg) {
        return new GatewayError(GatewayErrorType.SYSTEM_ERROR.getStatus(), code, msg);
    }

    public static GatewayError fail(GatewayErrorType error) {
        return new GatewayError(error.getStatus(), error.getCode(), error.getMsg());
    }
}
